﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsumerClient.ServiceReference1;

namespace ConsumerClient
{
    class DataGridItem
    {
        public string Date { get; set; }
        public string From { get; set; }
        public string Destination { get; set; }
        public string NoOfStations { get; set; }
        public string Car { get; set; }

        //public DataGridItem(DateTime date, WCFStation from, WCFStation destination, ICollection<WCFPartReservation> partReservations, WCFCar car)
        //{
        //    this.Date = date.ToString();
        //    this.From = from.City.ToString();
        //    this.Destination = destination.City.ToString();
        //    this.NoOfStations = partReservations.Count.ToString();
        //    this.Car = car.CarModel.Description.ToString();
        //}

        public DataGridItem(WCFReservation reservation)
        {
            this.Date = reservation.Date.ToShortDateString();
            this.From = UppercaseFirst(reservation.PartReservations.First().Station.City);
            this.Destination = UppercaseFirst(reservation.PartReservations.Last().Station.City);
            this.NoOfStations = reservation.PartReservations.Count().ToString();
            this.Car = reservation.Car.CarModel.Description;
        }

        private string UppercaseFirst(string s)
        {
            char[] a = s.ToLower().ToCharArray();
            a[0] = char.ToUpper(a[0]);
            return new string(a);
        }
    }
}
